package com.itheima.多线程.基础;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

public class Demo5 implements Callable<String> {
    @Override
    public String call() throws Exception {
        for (int i = 0; i < 100; i++) {
            System.out.println(Thread.currentThread().getName() + "........." + i);
        }
        return "成功";
    }
}

class Test5 {
    public static void main(String[] args) {
        Demo5 demo = new Demo5();
        FutureTask<String> future = new FutureTask<String>(demo);
        Thread th1 = new Thread(future, "线程一");
        Thread th2 = new Thread(future);
        th2.setName("线程二");
        th1.start();
        th2.start();


    }
}
